# -*- coding: utf-8 -*-
import scrapy
import re

class DoutuSpider(scrapy.Spider):
    name = 'doutu'
    allowed_domains = ['doutula.com']
    start_urls = ['https://www.doutula.com/photo/list/?page=1']

    def parse(self, response):
        imgs_url = re.findall('data-original="(.*?)"', response.text)
        print(imgs_url)
        next_url = response.xpath('//a[text()="›"]/@href').extract_first()
        print(next_url)
        print('第 {} 页url: '.format(next_url.split('=')[1]) + next_url)
        if next_url:
            yield response.follow(next_url, callback=self.parse)
